package com.xy.cli.command.children;

import com.xy.model.DataModel;
import com.xy.generator.MainGenerator;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import lombok.extern.slf4j.Slf4j;
import picocli.CommandLine;

import java.util.concurrent.Callable;

/**
* @author tzf
* @description: 生成低代码
* @date: 2024/6/14 15:35
*/
@Slf4j
@CommandLine.Command(name = "generate", description = "生成低代码", mixinStandardHelpOptions = true)
@Data
public class GenerateCommand implements Callable<Integer> {
        @CommandLine.Option(names = {"-l","--loop"}, arity = "0..1", description = "是否循环", interactive = true,echo=true)
        private boolean loop =false;
        @CommandLine.Option(names = {"-a","--author"}, arity = "0..1", description = "作者注释", interactive = true,echo=true)
        private String author ="tzf";
        @CommandLine.Option(names = {"-o","--outputText"}, arity = "0..1", description = "输出信息", interactive = true,echo=true)
        private String outputText ="sum=";

    @Override
    public Integer call() throws Exception {
    DataModel dataModel = DataModel.builder().build();
    BeanUtil.copyProperties(this, dataModel);
    log.info("配置信息=>{}", dataModel.toString());
    MainGenerator.doGenerate(dataModel);
    return 0;
    }
    }
